package juegohundirbarcos;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class tablero {

    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
    
    boolean[][] tablero = new boolean[7][7];

    public void colocaBarcos() {
        int contador=0;
        while(contador<5) {
            int fila = (int) (Math.random() * 7);            
            int columna = (int) (Math.random() * 7);
            if(!tablero[fila][columna]) {
                tablero[fila][columna] = true;
                contador++;
            }
        }
    }
    
    public void mostrar(){        
        for (int j = 0; j < 7; j++){
            for(int k = 0; k < 7; k++){
                if(tablero[j][k]){
                    System.out.print("X  ");
                }else{
                    System.out.print(".  ");
                }
            }
            System.out.println("");
        }
    }
    
    public void disparar() throws IOException{
        
        int fila, columna, contador = 0;
        
        while (contador < 5){
            System.out.println("\nDispara!");
            System.out.print("Fila: "); fila = Integer.parseInt(br.readLine())-1;
            System.out.print("Columna: "); columna = Integer.parseInt(br.readLine())- 1;
            if (tablero[fila][columna]){
                System.out.println("Hundido");
                contador++;
            }else{
                System.out.println("Agua");
            }
        }
        
    }
    
}
